<!--
 * @copyright: Huang Ding
 * @Author: ding-cx
 * @Date: 2021-04-02 14:52:26
 * @LastEditors: ding-cx
 * @LastEditTime: 2021-04-02 16:32:14
 * @Description: file content
-->
<template>
  <div
    class="icons-container"
    :style="{ '--var-themeColor': $store.state.settings.theme }"
  >
    <el-tabs type="border-card">
      <el-tab-pane label="SVG Icons">
        <base-scrollbar :height="400" :reduce="true">
          <div class="grid">
            <div
              v-for="item of svgIcons"
              :key="item"
              @click="handleClipboard(generateIconCode(item), $event)"
            >
              <!-- <el-tooltip placement="top">
                <div slot="content">
                  {{ generateIconCode(item) }}
                </div> -->
              <div class="icon-item">
                <svg-icon :icon-class="item" class-name="disabled" />
                <span>{{ item }}</span>
              </div>
              <!-- </el-tooltip> -->
            </div>
          </div>
        </base-scrollbar>
      </el-tab-pane>
      <el-tab-pane label="Element-UI Icons">
        <base-scrollbar :height="400" :reduce="true">
          <div class="grid">
            <div
              v-for="item of elementIcons"
              :key="item"
              @click="handleClipboard(generateElementIconCode(item), $event)"
            >
              <!-- <el-tooltip placement="top">
                <div slot="content">
                  {{ generateElementIconCode(item) }}
                </div> -->
              <div class="icon-item">
                <i :class="'el-icon-' + item" />
                <span>{{ item }}</span>
              </div>
              <!-- </el-tooltip> -->
            </div>
          </div>
        </base-scrollbar>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import clipboard from "@/utils/clipboard";
import svgIcons from "./svg-icons";
import elementIcons from "./element-icons";
import BaseScrollbar from "@/components/base/BaseScrollbar";

export default {
  name: "Icons",
  components: {
    BaseScrollbar,
  },
  data() {
    return {
      svgIcons,
      elementIcons,
    };
  },
  methods: {
    generateIconCode(symbol) {
      return symbol;
      // return `<svg-icon icon-class="${symbol}" />`;
    },
    generateElementIconCode(symbol) {
      return "el-icon-" + symbol;
      // return `<i class="el-icon-${symbol}" />`;
    },
    handleClipboard(text, event) {
      // clipboard(text, event);
      this.$emit("selected", text);
    },
  },
};
</script>

<style lang="scss" scoped>
.icons-container {
  margin: 10px 2px 0;
  overflow: hidden;

  .grid {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .icon-item {
    margin: 10px;
    height: 68px;
    text-align: center;
    width: 100px;
    float: left;
    font-size: 24px;
    color: #24292e;
    cursor: pointer;
    * {
      transition: all 160ms linear;
    }
    &:hover * {
      color: var(--var-themeColor);
      // color: #1890ff;
    }
  }

  span {
    display: block;
    font-size: 16px;
    margin-top: 10px;
  }

  .disabled {
    pointer-events: none;
  }
}
</style>
